const { resolve } = require("path")
const HtmlPlugin = require("html-webpack-plugin")
const CopyPlugin = require("copy-webpack-plugin")
module.exports = {
  entry: "./src/index.js",
  output: {
    filename: './js/app.bundle.js',
    path: resolve(__dirname, '../build'),
    clean: true,
    publicPath: "/",
  },
  mode: "production",
  // 设置ejs加载器
  module: {
    rules: [
      {
        test: /.\ejs$/,
        loader: "ejs-loader",
        options: {
          variable: "data",
        },
      },
    ],
  },
  plugins: [
    // 使用html导出插件
    new HtmlPlugin({
      template: "./public/index.html",
    }),
    // 使用复制插件导出html里链接的icon
    new CopyPlugin({
      patterns: [
        {
          from: "public",
          to: resolve(__dirname, "../build"),
          globOptions: {
            // htmlplug已经处理过index.html了. copyplug不要再处理index.html,否则无法打包
            ignore: ["**/index.html"],
          },
        },
      ],
    }),
  ],
  performance: {
    hints: false,  // 表示关闭性能提示
  },
}
